"""
食品分类用例
"""

from appium import webdriver
from time import  sleep
from  selenium.webdriver.common.by import By
import time

desired_capabilities={
    'platformName':'Android',
    'platformVersion':'7.1.2',
    'deviceName':'127.0.0.1:62001',
    'appPackage':'com.gfeng.daydaycook',
    'appActivity':'com.gfeng.daydaycook.activity.WelcomeActivity',
    'noReset':True,
    'newCommandTimeout':60,
    'unicodeKeyboard':True,
    'resetKeyboard':True
}
screen_name=time.strftime('%Y%m%d_%H%M%S')
driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_capabilities)
driver.implicitly_wait(30)
#数据
srnr='看起来不错哟'
#定位器
spfl_locator = (By.XPATH,'//android.widget.TextView[@text=\"食谱分类\"]')
zs_locator = (By.XPATH,'//android.widget.ListView[@resource-id=\"com.gfeng.daydaycook:id/leftListView\"]/android.widget.LinearLayout[5]')
sp_locator = (By.XPATH,'//android.widget.ListView[@resource-id=\"com.gfeng.daydaycook:id/rightListView\"]/android.widget.LinearLayout[1]/android.widget.GridView[1]/android.widget.RelativeLayout[1]')
zp_locator = (By.XPATH,'//android.widget.TextView[@text=\"作品\"]')
djzp_locator = (By.XPATH,'//android.support.v7.widget.RecyclerView[@resource-id=\"com.gfeng.daydaycook:id/recyclerView\"]/android.widget.RelativeLayout[1]')
djpl_locator = (By.ID,'com.gfeng.daydaycook:id/tv_comment')
input_locator = (By.ID,'com.gfeng.daydaycook:id/et_comment')

#操作
#点击食品分类
driver.find_element(*spfl_locator).click()
#点击主食
driver.find_element(*zs_locator).click()
#点击食品
driver.find_element(*sp_locator).click()
#点击作品
driver.find_element(*zp_locator).click()
#点击详细作品
driver.find_element(*djzp_locator).click()
#点击评论
driver.find_element(*djpl_locator).click()
#点击输入框
driver.find_element(*input_locator).click()
#输入框输入内容
driver.find_element(*input_locator).send_keys(srnr)